// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';
import 'package:flutter_layout/base/index.dart';
import 'package:flutter_layout/tools/print_utils.dart';
import 'package:get/get.dart';

class ThemePage extends StatefulWidget {
  const ThemePage({Key? key}) : super(key: key);

  @override
  _ThemePageState createState() => _ThemePageState();
}

// Brightness brightness, //深色还是浅色
// MaterialColor primarySwatch, //主题颜色样本，见下面介绍
// Color primaryColor, //主色，决定导航栏颜色
// Color accentColor, //次级色，决定大多数Widget的颜色，如进度条、开关等。
// Color cardColor, //卡片颜色
// Color dividerColor, //分割线颜色
// ButtonThemeData buttonTheme, //按钮主题
// Color cursorColor, //输入框光标颜色
// Color dialogBackgroundColor,//对话框背景颜色
// String fontFamily, //文字字体
// TextTheme textTheme,// 字体主题，包括标题、body等文字样式
// IconThemeData iconTheme, // Icon的默认样式
// TargetPlatform platform, //指定平台，应用特定平台控件风格
class _ThemePageState extends State<ThemePage> {
  final List<bool> _selecteds = [false, false, true];
  bool? _switchValue = false;
  @override
  Widget build(BuildContext context) {
    PrintUtils.printByApp("撒发大水代发as放到");
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        textSelectionTheme:
            const TextSelectionThemeData().copyWith(cursorColor: Colors.black, selectionColor: Colors.red),
        // platform: TargetPlatform.android,
        dialogBackgroundColor: Colors.orange,
// buttonTheme: ButtonBarTheme(),
        // brightness: Brightness.dark,
        brightness: Brightness.light,
        fontFamily: 'maobi',
        primarySwatch: Colors.yellow, //同时也控制了输入框的边缘线
        primaryColor: Colors.red,
        cardColor: Colors.purple,
        cursorColor: Colors.blue,
        accentColor: Colors.green,
        dividerColor: Colors.cyan,
        iconTheme: const IconThemeData(color: Colors.amber),
      ),
      home: Scaffold(
        resizeToAvoidBottomInset: true,
        appBar: AppBar(
          title: const Text('主题'),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              const SizedBox(
                height: 250,
              ),
              Checkbox(value: true, onChanged: (value) {}),
              const Text("ThemeData"),
              const Divider(
                thickness: 0.5, //高度
                indent: 20, //距离左边
                endIndent: 20, //距离右边
                // height: 30,
              ),
              ElevatedButton(
                  onPressed: () {
                    showDialog(
                        context: context,
                        builder: (context) {
                          return const AlertDialog(
                            title: Text("标题"),
                            content: Text("内容"),
                          );
                        });
                  },
                  child: const Text("按钮")),
              const TextField(
                autofocus: false,
              ),
              const TextField(
                showCursor: true,
                cursorWidth: 3,
                cursorRadius: Radius.circular(10),
                cursorColor: Colors.red,
              ),
              const Card(
                  child: SizedBox(
                width: 100,
                height: 50,
              )),
              RefreshIndicator(
                child: const Text("33333"),
                onRefresh: () async {},
              ),
              IconButton(onPressed: () {}, icon: const Icon(Icons.ac_unit)),
              const Icon(Icons.ac_unit_sharp),
              ToggleButtons(
                selectedColor: Colors.red,
                // focusColor: Colors.transparent,
                // disabledColor: Colors.transparent,
                fillColor: Colors.transparent,
                // highlightColor: Colors.transparent,
                // disabledColor: Colors.green,
                borderRadius: BorderRadius.circular(30),
                borderColor: Colors.red,
                color: Colors.grey.shade500,
                // renderBorder: false,
                isSelected: _selecteds,
                children: const <Widget>[
                  Icon(Icons.local_cafe),
                  Icon(Icons.fastfood),
                  Icon(Icons.cake),
                ],
                onPressed: (index) {
                  setState(() {
                    _selecteds[index] = !_selecteds[index];
                  });
                },
              ),
              ButtonTheme(
                textTheme: ButtonTextTheme.accent,
                child: RaisedButton(
                  child: const Text('老孟'),
                  onPressed: () {},
                ),
              ),
              dialogTheme(),
              const CircularProgressIndicator(),
              const RefreshProgressIndicator(),
              Slider(
                value: 1,
                onChanged: (value) {},
              ),
              RefreshIndicator(
                child: const Text("阿道夫"),
                onRefresh: () async {},
              ),
              Radio(
                value: 0.5,
                groupValue: "1",
                onChanged: (value) {},
                toggleable: true,
              ),
              Switch(
                value: _switchValue!,
                onChanged: (value) {
                  setState(() {
                    _switchValue = value;
                  });
                },
              )
            ],
          ),
        ),
        floatingActionButton: Theme(
          data: Theme.of(context).copyWith(
            colorScheme: Theme.of(context).colorScheme.copyWith(secondary: Colors.purple.shade200),
          ),
          child: const FloatingActionButton(
            onPressed: null,
            child: Icon(Icons.add),
          ),
        ),
      ),
    );
  }

  Widget dialogTheme() {
    return Theme(
      data: ThemeData(dialogBackgroundColor: Colors.pink.shade100),
      child: Builder(
        builder: (context) {
          var result = RaisedButton(
            onPressed: () async {
              var result = await showDialog(
                  context: context,
                  builder: (context) {
                    return AlertDialog(
                      title: const Text("标题"),
                      content: const Text("内容"),
                      actions: [
                        TextButton(
                            onPressed: () {
                              Get.back(result: "取消");
                            },
                            child: const Text("取消")),
                        TextButton(
                            onPressed: () {
                              Get.back(result: "确定");
                            },
                            child: const Text("确定"))
                      ],
                    );
                  });
              showToast("$result");
            },
            child: const Text("Show dialog"),
          );
          return result;
        },
      ),
    );
  }
}
